﻿#define _CRT_SECURE_NO_WARNINGS 1

#include <stdio.h>

int main() {
	int a, b;
	int i = 0;
	int j = 0;
	int arr1[1001];
	int arr2[1001];
	int arr[2002] = { 0 };
	scanf("%d %d", &a, &b);
	//输入数组a
	arr1[a] = 30000;
	arr2[b] = 30000;
	for (i = 0; i < a; i++)
	{
		scanf("%d", &arr1[i]);
	}
	//输入数组b
	for (i = 0; i < b; i++)
	{
		scanf("%d", &arr2[i]);
	}
	i = 0;
	j = 0;
	//合并数组
	while (i + j < a + b)
	{
		if (arr1[i] < arr2[j])
		{
			arr[i + j] = arr1[i];
			i++;
		}
		else
		{
			arr[i + j] = arr2[j];
			j++;
		}
	}
	//输出结果
	for (i = 0; i < a + b; i++)
	{
		printf("%d", arr[i]);
		if (i != a + b - 1)
			printf(" ");
	}
	return 0;
}